#ifdef TARG_SW5
cc = sw5cc -host -O3 
cc_slave = sw5cc -slave  -O3 
#endif


#ifdef X86
#CC=mcc
#CFLAGS=-O2
#
#OMPSS_FLAGS=--ompss-2
#LIBS=-lrt


SCHEDULER_INSTALL_PATH=${DAG_HOME}/dag_task_scheduler
EXTRA_FLAGS+=-DDAG 
#EXTRA_FLAGS+=-DMMEM 
EXTRA_FLAGS+=-DREDUCTION
EXTRA_FLAGS+= -DCHECK

CFLAGS = $(EXTRA_FLAGS)  -I${SCHEDULER_INSTALL_PATH}/include 

LIBFLAGS = -L${SCHEDULER_INSTALL_PATH}/lib -ldag_task_scheduler -lstdc++ -lm  -lswperf

OBJECT=04.dot_product_acemesh_slave.o 04.dot_product_acemesh.o main.o


SIZE=$$((1024*256))
CHUNK_SIZE=8192


dag: $(OBJECT) 04.dot_product_acemesh

04.dot_product_acemesh.o: 04.dot_product_acemesh.c
	$(cc) $(CFLAGS) -c 04.dot_product_acemesh.c 
04.dot_product_acemesh_slave.o:04.dot_product_acemesh_slave.c
	$(cc_slave) $(CFLAGS) -c 04.dot_product_acemesh_slave.c 
main.o:main.c
	$(cc) $(CFLAGS) -c main.c 
04.dot_product_acemesh:
	$(cc_slave) -hybrid   $(CFLAGS)  -o 04.dot_product_acemesh $(OBJECT) $(LIBFLAGS)


BIN=\
	01.dot_product_seq \
	02.dot_product_task+dep \
	03.dot_product_task+reduction \
	04.dot_product_acemesh \

all: $(BIN)

%_seq : %_seq.c main.c
	$(CC) $(CFLAGS) $^ -o $@ $(LIBS)

% : %.c main.c
	$(CC) $(CFLAGS) $(OMPSS_FLAGS) $^ -o $@ $(LIBS)

run: all
	./01.dot_product_seq $(SIZE) $(CHUNK_SIZE)
	./02.dot_product_task+dep $(SIZE) $(CHUNK_SIZE)
	./03.dot_product_task+reduction $(SIZE) $(CHUNK_SIZE)

clean:
	rm -f $(BIN)
	rm -f *.o
